#!/usr/bin/env bash
set -e
mkdir -p /opt/tmp

wget https://nodejs.org/dist/v8.9.1/node-v8.9.1-linux-x64.tar.xz
#xz -d node-v8.9.1-linux-x64.tar.xz
tar -xvf node-v8.9.1-linux-x64.tar
mv  node-v8.9.1-linux-x64 /opt/node
mv node-v8.9.1-linux-x64.tar /opt/tmp/



echo -e "export NODE_HOME=/opt/node\nexport PATH=\$NODE_HOME/bin:\$PATH">>/etc/profile
source /etc/profile
npm install -g cnpm --registry=https://registry.npm.taobao.org